package com.ruoyi.teach.event;

import com.ruoyi.teach.domain.TeachStudent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.stereotype.Component;

@Component
public class EventPublisher {

    @Autowired
    private ApplicationEventPublisher applicationEventPublisher;

    //发布事件-1-string
    public void doStuffAndPublishAnEvent(final String message) {
        System.out.println("Publishing custom CustomStudentChangeEvent.");
        CustomStudentChangeEvent customEvent = new CustomStudentChangeEvent(this, message);
        applicationEventPublisher.publishEvent(customEvent);
    }

    //发布事件-2-TeachStudent
    public void doStuffAndPublishAnEvent(final String message, TeachStudent teachStudent) {
        CustomStudentChangeEvent event = new CustomStudentChangeEvent(this, message, teachStudent);
        applicationEventPublisher.publishEvent(event);
    }

}
